package com.zlc.platform.controller;


import com.zlc.common.annotation.LogSaveAnnotation;
import com.zlc.common.common.constant.PlatConstant;
import com.zlc.common.common.entity.PageVo;
import com.zlc.common.core.position.model.entity.MayanPlatPosition;
import com.zlc.common.core.position.model.vo.MayanPlatPositionVo;
import com.zlc.common.model.position.PositionPageRequest;
import com.zlc.platform.service.PositionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(tags = "岗位相关")
@RestController
@Slf4j
@RequestMapping("/api/position")
public class PositionController {

    @Autowired
    private PositionService positionService;

    /**
     * 分页查询岗位信息
     */
    @ApiOperation(value = "分页查询岗位信息")
    @PostMapping(value = "/queryList")
    public PageVo<MayanPlatPositionVo> queryList(@RequestBody PositionPageRequest pageRequest){
        return positionService.queryList(pageRequest);
    }


    /**
     * 新增岗位信息
     */
    @ApiOperation(value = "新增岗位信息")
    @PostMapping(value = "/addPosition")
    @LogSaveAnnotation(module = PlatConstant.UC_APP_MODULE, recordRequestParam = true, title = "新增岗位信息", catalog = "权限管理/岗位管理")
    public void addPosition(@RequestBody MayanPlatPositionVo positionVo){
        positionService.addPosition(positionVo);
    }


    /**
     * 更新岗位信息
     */
    @ApiOperation(value = "更新岗位信息")
    @PostMapping(value = "/updatePosition")
    @LogSaveAnnotation(module = PlatConstant.UC_APP_MODULE, recordRequestParam = true, title = "更新岗位信息", catalog = "权限管理/岗位管理")
    public void updatePosition(@RequestBody MayanPlatPositionVo positionVo){
        positionService.updatePosition(positionVo);
    }


    /**
     * 查询单个岗位信息
     */
    @ApiOperation(value = "查询单个岗位信息")
    @PostMapping(value = "/get")
    public MayanPlatPosition get(@RequestParam(value = "id") String id){
        return positionService.get(id);
    }
}
